package com.jsu.service.impl;

import com.jsu.mapper.ActivityMapper;
import com.jsu.mapper.AgendaMapper;
import com.jsu.mapper.RegistrationMapper;
import com.jsu.service.DataService;
import org.checkerframework.checker.units.qual.A;
import org.example.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class DataServiceImpl implements DataService {

    @Autowired
    private ActivityMapper activityMapper;
    @Autowired
    private AgendaMapper agendaMapper;
    @Autowired
    private RegistrationMapper registrationMapper;

    @Override
    public Map<String, Integer> count() {
        //需要做浏览量、点赞量、订阅量、报名量的总统计
        Integer activityLikes = activityMapper.countLikes();
        Integer activitySubs = activityMapper.countSubs();
        Integer activityViews = activityMapper.countViews();
        //agenda类似
        Integer agendaLikes = agendaMapper.countLikes();
        Integer agendaSubs = agendaMapper.countSubs();
        Integer agendaViews = agendaMapper.countViews();

        //re
        Integer registrationCount = registrationMapper.count();
        Map<String, Integer> result = new HashMap<>();
        result.put("likes", activityLikes+agendaLikes);
        result.put("subs", activitySubs+agendaSubs);
        result.put("views", activityViews+agendaViews);
        result.put("regs", registrationCount);
        return result;
    }

    @Override
    public ResponseResult registrations() {
        //需要做报名统计
        List<Integer> countRegistrations = registrationMapper.countRegistrations();
        return ResponseResult.okResult(countRegistrations);
    }
}